package IC.AST;

import IC.SymbolTable.SymbolTable;
import IC.Types.Type;

/**
 * Abstract AST node base class.
 * 
 * @author Tovi Almozlino
 */
public abstract class ASTNode {

	private int line;
	private SymbolTable Scope;
	private Type NodeType = null;

	/**
	 * Double dispatch method, to allow a visitor to visit a specific subclass.
	 * 
	 * @param visitor
	 *            The visitor.
	 * @return A value propagated by the visitor.
	 */
	public abstract Object accept(Visitor visitor);
	
	public abstract <D, U> U accept(PropagatingVisitor<D, U> visitor, D d) throws Exception;
	
	/**
	 * Constructs an AST node corresponding to a line number in the original
	 * code. Used by subclasses.
	 * 
	 * @param line
	 *            The line number.
	 */
	protected ASTNode(int line) {
		this.line = line;
	}

	public int getLine() {
		return line;
	}
	
	public void setScope(SymbolTable Scope) {
		this.Scope = Scope;
	}

	public SymbolTable getScope() {
		return Scope;
	}
	
	public IC.Types.Type getNodeType() {
		return NodeType;
	}

	public void setNodeType(Type NodeType) {
		this.NodeType = NodeType;
	}

}
